/**
 * <copyright>
 * </copyright>
 *

 */
package org.xtext.example.cr.cR.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.example.cr.cR.CRPackage;
import org.xtext.example.cr.cR.IntDec;
import org.xtext.example.cr.cR.PartitionDec;
import org.xtext.example.cr.cR.PrimitiveDec;
import org.xtext.example.cr.cR.RealDec;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Primitive Dec</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrimitiveDecImpl#getIntDec <em>Int Dec</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrimitiveDecImpl#getRealDec <em>Real Dec</em>}</li>
 *   <li>{@link org.xtext.example.cr.cR.impl.PrimitiveDecImpl#getPartitionDec <em>Partition Dec</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PrimitiveDecImpl extends MinimalEObjectImpl.Container implements PrimitiveDec
{
  /**
   * The cached value of the '{@link #getIntDec() <em>Int Dec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getIntDec()
   * @generated
   * @ordered
   */
  protected IntDec intDec;

  /**
   * The cached value of the '{@link #getRealDec() <em>Real Dec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getRealDec()
   * @generated
   * @ordered
   */
  protected RealDec realDec;

  /**
   * The cached value of the '{@link #getPartitionDec() <em>Partition Dec</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPartitionDec()
   * @generated
   * @ordered
   */
  protected PartitionDec partitionDec;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected PrimitiveDecImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return CRPackage.Literals.PRIMITIVE_DEC;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public IntDec getIntDec()
  {
    return intDec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetIntDec(IntDec newIntDec, NotificationChain msgs)
  {
    IntDec oldIntDec = intDec;
    intDec = newIntDec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.PRIMITIVE_DEC__INT_DEC, oldIntDec, newIntDec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setIntDec(IntDec newIntDec)
  {
    if (newIntDec != intDec)
    {
      NotificationChain msgs = null;
      if (intDec != null)
        msgs = ((InternalEObject)intDec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.PRIMITIVE_DEC__INT_DEC, null, msgs);
      if (newIntDec != null)
        msgs = ((InternalEObject)newIntDec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.PRIMITIVE_DEC__INT_DEC, null, msgs);
      msgs = basicSetIntDec(newIntDec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.PRIMITIVE_DEC__INT_DEC, newIntDec, newIntDec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RealDec getRealDec()
  {
    return realDec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetRealDec(RealDec newRealDec, NotificationChain msgs)
  {
    RealDec oldRealDec = realDec;
    realDec = newRealDec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.PRIMITIVE_DEC__REAL_DEC, oldRealDec, newRealDec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setRealDec(RealDec newRealDec)
  {
    if (newRealDec != realDec)
    {
      NotificationChain msgs = null;
      if (realDec != null)
        msgs = ((InternalEObject)realDec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.PRIMITIVE_DEC__REAL_DEC, null, msgs);
      if (newRealDec != null)
        msgs = ((InternalEObject)newRealDec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.PRIMITIVE_DEC__REAL_DEC, null, msgs);
      msgs = basicSetRealDec(newRealDec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.PRIMITIVE_DEC__REAL_DEC, newRealDec, newRealDec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public PartitionDec getPartitionDec()
  {
    return partitionDec;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetPartitionDec(PartitionDec newPartitionDec, NotificationChain msgs)
  {
    PartitionDec oldPartitionDec = partitionDec;
    partitionDec = newPartitionDec;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CRPackage.PRIMITIVE_DEC__PARTITION_DEC, oldPartitionDec, newPartitionDec);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPartitionDec(PartitionDec newPartitionDec)
  {
    if (newPartitionDec != partitionDec)
    {
      NotificationChain msgs = null;
      if (partitionDec != null)
        msgs = ((InternalEObject)partitionDec).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CRPackage.PRIMITIVE_DEC__PARTITION_DEC, null, msgs);
      if (newPartitionDec != null)
        msgs = ((InternalEObject)newPartitionDec).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CRPackage.PRIMITIVE_DEC__PARTITION_DEC, null, msgs);
      msgs = basicSetPartitionDec(newPartitionDec, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, CRPackage.PRIMITIVE_DEC__PARTITION_DEC, newPartitionDec, newPartitionDec));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case CRPackage.PRIMITIVE_DEC__INT_DEC:
        return basicSetIntDec(null, msgs);
      case CRPackage.PRIMITIVE_DEC__REAL_DEC:
        return basicSetRealDec(null, msgs);
      case CRPackage.PRIMITIVE_DEC__PARTITION_DEC:
        return basicSetPartitionDec(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case CRPackage.PRIMITIVE_DEC__INT_DEC:
        return getIntDec();
      case CRPackage.PRIMITIVE_DEC__REAL_DEC:
        return getRealDec();
      case CRPackage.PRIMITIVE_DEC__PARTITION_DEC:
        return getPartitionDec();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case CRPackage.PRIMITIVE_DEC__INT_DEC:
        setIntDec((IntDec)newValue);
        return;
      case CRPackage.PRIMITIVE_DEC__REAL_DEC:
        setRealDec((RealDec)newValue);
        return;
      case CRPackage.PRIMITIVE_DEC__PARTITION_DEC:
        setPartitionDec((PartitionDec)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.PRIMITIVE_DEC__INT_DEC:
        setIntDec((IntDec)null);
        return;
      case CRPackage.PRIMITIVE_DEC__REAL_DEC:
        setRealDec((RealDec)null);
        return;
      case CRPackage.PRIMITIVE_DEC__PARTITION_DEC:
        setPartitionDec((PartitionDec)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case CRPackage.PRIMITIVE_DEC__INT_DEC:
        return intDec != null;
      case CRPackage.PRIMITIVE_DEC__REAL_DEC:
        return realDec != null;
      case CRPackage.PRIMITIVE_DEC__PARTITION_DEC:
        return partitionDec != null;
    }
    return super.eIsSet(featureID);
  }

} //PrimitiveDecImpl
